package com.konglz.publisher.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author konglz
 * @Data 2023/5/13 11:24
 */
@RestController
@ApiOperation("简单消息模型")
@RequestMapping("/simple")
public class SimpleMessageController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
    * @Description: 简单信息模型案例
    * @return: void
    * @Author: konglz
    * @Date: 2023/5/13
    */
    @GetMapping("/{message}")
    @ApiOperation("测试简单消息队列")
    public void simple(@PathVariable String message){
        String queueName = "queue1";
        rabbitTemplate.convertAndSend(queueName,message);
    }

    /**
    * @Description: 传输对象
    * @return: void
    * @Author: konglz
    * @Date: 2023/5/13
    */
    void ObjectQueue(){
        Map<String,Object> message = new HashMap<>();
        message.put("name","konglz");
        message.put("age", "3");
        rabbitTemplate.convertAndSend("objectQueue", message);
    }
}
